<?php
$_SESSION["backref"] = "<a href=\"/\" class=\"backreference\">Главная</a>";
if(!isset($_GET["catalogue"]) || $_GET["catalogue"]==""){
	$_GET["catalogue"] = "all/";
}

	$query = "SELECT parent.cat_link, parent.cat_name 
		FROM kpulse_categories AS node,
		kpulse_categories AS parent
		WHERE node.cat_lft BETWEEN parent.cat_lft AND parent.cat_rgt
		AND node.cat_link = '". $_GET["catalogue"] ."'
		AND parent.cat_id > 1
		ORDER BY parent.cat_lft";
	$result = mysql_query($query) or die(mysql_error() ."<br>". $query);
	while($row=mysql_fetch_array($result, MYSQL_ASSOC)){
		$_SESSION["backref"] .= ">><a href=\"catalogue/". $row["cat_link"] ."\" class=\"backreference\">". $row["cat_name"] ."</a>";
	}
	echo $_SESSION["backref"];
?>